*Do-File for creating Table 1
*Provides some basic breakdowns by gender, race, cause of death, whether armed, and behavioral health

***File set-up
macro drop _all
mat drop _all
eststo clear
estimates clear
global path "[ENTER PATH HERE]"
global figs "$path\REStat Replication V2\Figures"
global log "$path\REStat Replication V2\Log Files"
set scheme lean2

clear
set more off

cap log close
log using "$log\table_1_log.txt", replace text

use "$path\REStat Replication V2\Data\master_data_analysis_subset"
*Set folder for main figures
cd "$figs"


***Summary stats for Table 1 on OFs, race, age, gender, cause of death
*Mean Age and News Results
*By race, gender, mental illness, and cause of death
di "OF Victim Characteristic Sum Stats"
*Create indicator variable for high-profile police killings in analysis sample
	*Determine the number of events
	*Subset on "blk" indicator to not duplicate the num of obs
gen in_analysis_samp = 1 if !mi(victim_name) & blk == 1 & !mi(ln_lowMB, ln_pop_s, ///
	ln_actual_index_violent, ln_actual_index_property)
distinct ori if in_analysis_samp == 1
local obs = r(N)
local source "Fatal Encounters (2005--2016); `obs' observations; ASR Sample"
di "`source'"

***Generate summary statistic table

*Need to set these variable values from Unknown to missing for this table output
replace beh_health = "" if beh_health == "Unknown"
replace unarmed = "" if unarmed == "Unknown"
	
	
*Manually inputted into latex after this prints for paper version
	*A few % need to be rounded up to closest whole number
tabout victim_gender victim_race cause_of_death unarmed beh_health ///
	if in_analysis_samp == 1 ///
	using "$figs\table_1.txt", ///
	cells(mean num_news_results ///
	count num_news_results) format(0c 0c) ///
	clab("Avg._News" "Number") ///
	oneway sum npos(tufte) replace ///
    style(tab)
	
	
/*Latex version, but doesn't reproduce exactly
tabout victim_gender victim_race cause_of_death unarmed beh_health ///
	if in_analysis_samp == 1 ///
	using "$figs\table_1.tex", ///
	cells(mean num_news_results ///
	count num_news_results) format(1c 0c) ///
	clab("Mean News Articles" "Number") ///
	oneway sum npos(tufte) replace ///
    style(tex) bt font(bold) ///
	botstr(`source')
*/


cap log close

